﻿



@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>

    $(function () {
        gridList();
    });
    function gridList() {
        var $gridList = $("#gridList");
       
        $.ajax({
            type: 'get',
            datatype: "json",
            url: "/SystemManage/SysUser/GetDictionaryJson",
            success: function (data) {
                var userData = JSON.parse(data); 
                $gridList.dataGrid({
                    url: "/SystemManage/SysDbBackup/GetGridPaginationJson",
                    height: $(window).height() - 120,
                    colModel: [
                         { label: "主键", name: "Id", hidden: true, key: true },
                         { label: '数据库名', name: 'DbName', width: 100, align: 'left' },
                         { label: '备份名称', name: 'FileName', width: 200, align: 'left' },
                         { label: '大小', name: 'FileSize', width: 100, align: 'left' },
                         {
                             label: '备份模式', name: 'BackupType', width: 100, align: 'left',
                             formatter: function (cellvalue) {
                                 if (cellvalue === "1") {
                                     return "完整备份";
                                 } else if (cellvalue === "2") {
                                     return "差异备份";
                                 } else {
                                     return "";
                                 }
                             }
                         },
                         {
                             label: '备份时间', name: 'CreatorTime', width: 120, align: 'left',
                             formatter: "date", formatoptions: { srcformat: 'Y-m-d H:i', newformat: 'Y-m-d H:i' }
                         },
                         {
                             label: '备份人员', name: 'CreatorUserId', width: 120, align: 'left', formatter: function (cellvalue) {
                                 return userData[cellvalue] == null ? "" : userData[cellvalue].fullname;
                             }
                         },
                         { label: '备份说明', name: 'Description', width: 300, align: 'left' }
                    ],
                    pager: "#gridPager",
                    sortname: 'CreatorTime',
                    rowNum: 20,
                    rowList: [20, 50, 100, 200],
                    viewrecords: true
                });
            }
        });
        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam', {
                postData: { queryJson: $("#txt_keyword").val() }
            }).trigger('reloadGrid');
        });
    }
    function btn_add() {
        $.modalOpen({
            id: "Form",
            title: "新建数据库备份",
            url: "/SystemManage/SysDbBackup/Form",
            width: "450px",
            height: "768px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    function btn_delete() {
        $.deleteForm({
            url: "/SystemManage/SysDbBackup/DeleteForm",
            param: { keyValue: $("#gridList").jqGridRowValue().Id },
            success: function () {
                $("#gridList").trigger("reloadGrid");
            }
        });
    }

    function btn_download() {
        var keyValue = $("#gridList").jqGridRowValue().Id;
        $.download("/SystemManage/SysDbBackup/DownloadBackup", "keyValue=" + keyValue, 'post');
    }

    //function btn_details() {
    //    var keyValue = $("#gridList").jqGridRowValue().Id;
    //     if (keyValue === undefined) {
    //        layer.msg('请选中行');
    //    } else {
    //		$.modalOpen({
    //			id: "Details",
    //			title: "查看数据库备份",
    //			url: "/SystemManage/SysDbBackup/Details?keyValue=" + keyValue,
    //			width: "450px",
    //			height: "768px",
    //			btn: null
    //		});
    //	}
    //}
</script>
<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
            <a id="NF-add" class="btn btn-primary dropdown-text" onclick="btn_add()"><i class="fa fa-plus"></i>新建备份</a>
        </div>
        <div class="operate">
            <ul class="nav nav-pills">
                <li class="first">已选中<span>1</span>项</li>
                <li><a id="NF-delete" authorize="yes" onclick="btn_delete()"><i class="fa fa-trash-o"></i>删除备份</a></li>
                <li class="split"></li>
                <li><a id="NF-download" authorize="yes" onclick="btn_download()"><i class="fa fa-cloud-download"></i>下载备份</a></li>


            </ul>
            <a href="javascript:;" class="close"></a>
        </div>
        <script>$('.toolbar').authorizeButton()</script>
    </div>
    <div class="search">
        <table>
            <tr>
                <td>
                    <div class="input-group">
                        <input id="txt_keyword" type="text" class="form-control" placeholder="请输入要查询关键字" style="width: 200px;">
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn  btn-primary"><i class="fa fa-search"></i></button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>
<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>




